package com.vains.controller;

import com.vains.bean.Result;
import com.vains.service.IOauthPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 权限管理接口
 *
 * @author vains
 * @date 2021/4/10 12:54
 */
@RestController
@AllArgsConstructor
@Api(tags = "权限接口")
@RequestMapping("/permission")
public class OauthPermissionController {

    private final IOauthPermissionService iOauthPermissionService;

    @ApiParam(name = "userId", value = "用户ID")
    @GetMapping("/findPermissionsByUserId/{userId}")
    @ApiOperation(value = "根据用户id获取用户拥有的权限", hidden = true)
    public Result<List<String>> findPermissionsByUserId(@PathVariable Long userId) {
        List<String> permissions = iOauthPermissionService.findPermissionsByUserId(userId);
        return Result.success(permissions);
    }

}
